import { fetchGet } from '../utils/http'

/**
 * 数据集列表
 */
export const getDatalabList = () => {
    return fetchGet("/data/list")
}

/**
 * 关键词查询或标签查询
 */
export const searchData = (params) => {
    if(params.filterBy === "keyword"){
        return fetchGet("/data/search",{key:params.inputValue})
    }else if(params.filterBy === "label"){
        return fetchGet("/data/searchByLabel",{label:params.inputValue})
    }
}

/**
 * 数据详情
 */
export const getDataDetail = (params) => {
    return fetchGet("/data/getDataDetail",{data_id:params})
}

/**
 * 数据是否点赞
 */
export const hasVoted = (params) => {
    return fetchGet("/data/hasVoted",{data_id:params})
}

/**
 * 点赞取消赞
 */
export const toggleVote = (params) => {
    if(params.voted){
        return fetchGet("/data/voteDown",{data_id:params.data_id})
    }else{
        return fetchGet("/data/voteUp",{data_id:params.data_id})
    }
}

/**
 * 数据概述
 */
export const getDataDesc = (params) => {
    return fetchGet("/data/getDataInfo",{data_id:params})
}

/**
 * 数据文件
 */
export const getDataFile = (params) => {
    return fetchGet("/data/getDataFile",{data_id:params})
}

/**
 * 单个数据集任务历史资源查看
 */
export const getNotebookUrl = (params) => {
    return fetchGet("task/view",{
        data_id:params.data_id,
        notebook_id:params.notebook_id
    })
}


/**
 * 数据平台notebook界面数据目录
 */
export const getDirlist = (params) => {
    return fetchGet("/notebook/listDir",{
        from_type:params.from_type,
        path:params.path,
        task_id:params.task_id
    })
}